package com.antler.smt.portal.controller;

import com.antler.smt.entity.ItemsEntity;
import com.antler.smt.response.base.Result;
import com.antler.smt.service.portal.WeChatPayService;
import com.antler.smt.utils.LogUtil;
import com.antler.smt.validate.DataValidator;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.slf4j.Logger;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


/**
 * 微信支付接口 TODO
 *
 * @author zhangyi
 * @date 2018/6/4 14:42
 */
@RestController
@RequestMapping("/pay")
@Api(description = "微信支付接口(待完成)")
public class WeChatPayController {

    /**
     * 日志
     */
    public static final Logger log = LogUtil.get();

    @Resource
    private WeChatPayService weChatPayService;

    /**
     * 微信支付接口,返回支付二维码
     *
     * @param itemsEntity
     * @return
     */
    @PostMapping("/payOrder")
    @ApiOperation(value = "微信支付接口,返回支付二维码",httpMethod = "POST")
    public void payOrder(@RequestBody ItemsEntity itemsEntity, HttpServletRequest request, HttpServletResponse response){

        DataValidator.isNull(itemsEntity,"商品实体不为空！");
            weChatPayService.qrCode(itemsEntity,request,response);
    }

    /**
     * 微信回调接口
     *
     * @return
     */
    @PostMapping("/syntony")
    @ApiOperation(value = "微信回调接口",httpMethod = "POST")
    public Result syntony(){

        Result result = null;

        return result;
    }
}
